package net.bwie.realtime.traffic.service.trafficrealtimeservice.mapper;

import net.bwie.realtime.traffic.service.trafficrealtimeservice.bean.SugarIllegalEvents;
import net.bwie.realtime.traffic.service.trafficrealtimeservice.bean.SugarTwo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TrafficMapper {
    @Select("SELECT \n" +
            "    licensePlate, roadId, lane, eventType\n" +
            "FROM traffic_monitoring.dwd_traffic_illegal_events\n" +
            "WHERE toDate(toDateTime(ts/1000)) = #{date}\n" +
            "ORDER BY ts DESC LIMIT 10")
    List<SugarIllegalEvents> getIllegalEvents(@Param("date") String date);

    @Select("SELECT\n" +
            "    eventType AS name,sum(count) AS value\n" +
            "FROM traffic_monitoring.dwd_traffic_illegal_type\n" +
            "WHERE toDate(toDateTime(ts/1000)) = #{date}\n" +
            "GROUP BY eventType")
    List<SugarTwo> getIllegalType(@Param("date") String date);
}
